package com.bzqn.baseframe;

import java.util.List;

import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;

public class MyViewPagerAdapter extends PagerAdapter{  
    private List<TabButtonConfig> buttons;  
      
    public MyViewPagerAdapter(List<TabButtonConfig> buttons) {  
        this.buttons = buttons;//构造方法，参数是我们的页卡，这样比较方便。  
    }  

    @Override  
    public void destroyItem(ViewGroup container, int position, Object object)   {     
        container.removeView(buttons.get(position).getTabContentView());//删除页卡  
    }  


    @Override  
    public Object instantiateItem(ViewGroup container, int position) {  //这个方法用来实例化页卡         
         container.addView(buttons.get(position).getTabContentView(), 0);//添加页卡  
         return buttons.get(position).getTabContentView();  
    }  

    @Override  
    public int getCount() {           
        return  buttons.size();//返回页卡的数量  
    }  
      
    @Override  
    public boolean isViewFromObject(View arg0, Object arg1) {             
        return arg0==arg1;//官方提示这样写  
    }  
}  

